package com.aynu.gulimall.order.web;

import com.aynu.gulimall.order.entity.OrderEntity;
import org.checkerframework.checker.units.qual.A;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author mj
 * @version 1.0
 * @date 2021/3/21 11:23
 */
@Controller
public class HelloController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/test/ordermq")
    @ResponseBody
    public String mqtest(){
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn("12121212");
        orderEntity.setCreateTime(new Date());

        //给mq发送消息
        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);

        return "ok";
    }

    @GetMapping("/{page}.html")
    public String page(@PathVariable("page")String page){
        return page;
    }
}
